<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );

$strAll =  aac('group')->findAll ('group','isplace=2 and groupid<>1');
$strPro = array();

foreach($strAll as $k){
	if(!in_array($k['province'],$strPro)){
			$strPro[] = $k['province'];
	}
}

foreach($strPro as $k => $v){
	$arrGroup[$k]['pro'] = $v;
	$arrGroup[$k]['sum']['sum'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'"');
	$arrGroup[$k]['sum']['yun'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and status=2');
	$arrGroup[$k]['sum']['chou'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and status=1');
	$arrGroup[$k]['sum']['ting'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and status=0');
	$arrGroup[$k]['sum']['zhu'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and isassist=0');
	$arrGroup[$k]['sum']['xie'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and isassist=1');
	$arrGroup[$k]['sum']['li'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and iscouncil=1');
	$arrGroup[$k]['sum']['daili'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and iscouncil=0 and isdonate=1');
	$arrGroup[$k]['sum']['guan'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and isassist=0 and isserver=0 and status<>0');
	$strGroup = aac('group')->findAll ('group',array('province'=>$v,'isplace'=>2));
	$strCity = array();
	foreach($strGroup as $u){
		if($u['groupid']>1){
			if(!in_array($u['city'],$strCity)){
				$strCity[] = $u['city'];
			}
		}
	}

	$arrGroup[$k]['count'] = 1;
	foreach($strCity as $i => $item){
		$arrGroup[$k]['city'][$i]['cityname'] = $item;
		$arrGroup[$k]['city'][$i]['sum'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and city="'.$item.'"');
		$arrGroup[$k]['city'][$i]['yun'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and city="'.$item.'" and status=2');
		$arrGroup[$k]['city'][$i]['chou'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and city="'.$item.'" and status=1');
		$arrGroup[$k]['city'][$i]['ting'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and city="'.$item.'" and status=0');
		$arrGroup[$k]['city'][$i]['zhu'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and city="'.$item.'" and isassist=0');
		$arrGroup[$k]['city'][$i]['xie'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and city="'.$item.'" and isassist=1');
		$arrGroup[$k]['city'][$i]['li'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and city="'.$item.'" and iscouncil=1');
		$arrGroup[$k]['city'][$i]['daili'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and city="'.$item.'" and iscouncil=0 and isdonate=1');
		$arrGroup[$k]['city'][$i]['guan'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and province="'.$v.'" and city="'.$item.'" and isassist=0 and isserver=0 and status<>0');
		$arrGroup[$k]['count'] = $arrGroup[$k]['count']+1;
	}
}

$arrGroup['sum']['sum'] = aac('group')->findCount('group','isplace=2 and groupid<>1');
$arrGroup['sum']['yun'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and status=2');
$arrGroup['sum']['chou'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and status=1');
$arrGroup['sum']['ting'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and status=0');
$arrGroup['sum']['zhu'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and isassist=0');
$arrGroup['sum']['xie'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and isassist=1');
$arrGroup['sum']['li'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and iscouncil=1');
$arrGroup['sum']['daili'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and iscouncil=0 and isdonate=1');
$arrGroup['sum']['guan'] = aac('group')->findCount('group','isplace=2 and groupid<>1 and isassist=0 and isserver=0 and status<>0');
$title = '各馆统计';

include template ( "sum" );